package com.qu.waibao;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;

import com.alibaba.mobileim.YWAPI;
import com.alibaba.mobileim.aop.AdviceBinder;
import com.alibaba.mobileim.aop.PointCutEnum;
import com.alibaba.wxlib.util.SysUtil;
import com.mob.MobSDK;
import com.qu.waibao.baidu.LocationUtils;
import com.qu.waibao.baidu.openim.ChattingUICustomSample;
import com.qu.waibao.baidu.openim.ConversationListUICustomSample;
import com.squareup.leakcanary.LeakCanary;

import org.xutils.x;

/**
 * Created by Administrator on 2018/7/21.
 */

public class MyApplication extends MultiDexApplication {
    private static MyApplication application;
    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        LocationUtils.getLocationUtils().init(this);
        x.Ext.init(this);
        x.Ext.setDebug(BuildConfig.DEBUG); // 是否输出debug日志, 开启debug会影响性能.
        //必须首先执行这部分代码, 如果在":TCMSSevice"进程中，无需进行云旺（OpenIM）和app业务的初始化，以节省内存;
        SysUtil.setApplication(this);
        if (SysUtil.isTCMSServiceProcess(this)) {
            return;
        }
        //第一个参数是Application Context
        //这里的APP_KEY即应用创建时申请的APP_KEY，同时初始化必须是在主进程中
        if (SysUtil.isMainProcess()) {
            YWAPI.init(this, AppConfig.APP_KEY);
        }
        AdviceBinder.bindAdvice(PointCutEnum.CHATTING_FRAGMENT_UI_POINTCUT, ChattingUICustomSample.class);
        AdviceBinder.bindAdvice(PointCutEnum.CONVERSATION_FRAGMENT_UI_POINTCUT, ConversationListUICustomSample.class);
       /* if (LeakCanary.isInAnalyzerProcess(this)) {
            return;
        }
        LeakCanary.install(this);*/
        MobSDK.init(this);
    }

    public static MyApplication getInstance(){
        return application;
    }
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }


}
